/**
 * Licensee: Universidad de Almeria
 * License Type: Purchased
 */
package ormsamples;

import org.orm.*;
public class RetrieveAndUpdatePractica1Data {
	public void retrieveAndUpdateTestData() throws PersistentException {
		PersistentTransaction t = agenda.Practica1PersistentManager.instance().getSession().beginTransaction();
		try {
			agenda.Registro lagendaRegistro = agenda.RegistroDAO.loadRegistroByQuery(null, null);
			// Update the properties of the persistent object
			agenda.RegistroDAO.save(lagendaRegistro);
			t.commit();
		}
		catch (Exception e) {
			t.rollback();
		}
		
	}
	
	public void retrieveByCriteria() throws PersistentException {
		System.out.println("Retrieving Registro by RegistroCriteria");
		agenda.RegistroCriteria registroCriteria = new agenda.RegistroCriteria();
		// Please uncomment the follow line and fill in parameter(s)
		//registroCriteria.telefono.eq();
		System.out.println(registroCriteria.uniqueRegistro());
		
	}
	
	
	public static void main(String[] args) {
		try {
			RetrieveAndUpdatePractica1Data retrieveAndUpdatePractica1Data = new RetrieveAndUpdatePractica1Data();
			try {
				retrieveAndUpdatePractica1Data.retrieveAndUpdateTestData();
				//retrieveAndUpdatePractica1Data.retrieveByCriteria();
			}
			finally {
				agenda.Practica1PersistentManager.instance().disposePersistentManager();
			}
		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}
}
